package com.bawei.model_sevent.Activity.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.bawei.model_sevent.R;
import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;

import java.util.ArrayList;

import static com.tencent.live2.V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit;

public class MainActivity_zhibo extends AppCompatActivity {

    private Button stop;
    private Button pose;
    private Button next;
    private Button begin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_zhibo);
        initView();
        //mPlayerView 即 step1 中添加的界面 view
        TXCloudVideoView mView = (TXCloudVideoView) findViewById(R.id.video_view);
//创建 player 对象
        V2TXLivePlayer mLivePlayer = new V2TXLivePlayerImpl(this);
//关键 player 对象与界面 view
        mLivePlayer.setRenderView(mView);

        // 设置填充模式
        mLivePlayer.setRenderFillMode(V2TXLiveFillModeFit);
        ArrayList<String> strings = new ArrayList<>();
        strings.add("rtmp://mobliestream.c3tv.com:554/live/goodtv.sdp");
        strings.add("rtmp://ns8.indexforce.com/home/mystream");
        
        begin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mLivePlayer.startPlay(strings.get(0));
            }
        });
        stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 暂停
                mLivePlayer.pauseAudio();
                mLivePlayer.pauseVideo();
            }
        });
        pose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 继续
                mLivePlayer.resumeAudio();
                mLivePlayer.resumeVideo();
            }
        });
        next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mLivePlayer.startPlay(strings.get(1));
            }
        });
    }

    private void initView() {
        stop = findViewById(R.id.stop);
        pose = findViewById(R.id.pose);
        next = findViewById(R.id.next);
        begin = findViewById(R.id.begin);
    }
}